

clear

use "main.dta"

cd "..."

global controls  ft_age age1 age2 age3 age4 age5 age6 age7 age8 age9

***********
* Table 1 *
***********

sort id_lav anno

*All workers*

*<10%
reghdfe d.logwaged c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv $controls [aw=peso] if dum010liv==1 & (qual=="1" | qual=="2") & mtm==1, absorb(anno id_lav#id_az) cluster(id_azienda id_lav) nocon
testparm c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv c.neg_ft_tfp_solow_GMM_CD c.lag_bite010liv
local pval: display %-9.3f r(p)
outreg2 using table1, replace tex excel dec(3) ctitle(Delta log Wage all workers 0-10%) addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, Yes,  p-value, `pval') keep(neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)
*>10%
reghdfe d.logwaged c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv $controls  [aw=peso] if dum010liv==0 & (qual=="1" | qual=="2") & mtm==1, absorb(anno id_lav#id_az) cluster(id_azienda id_lav) nocon
sum c.lag_bite010liv [aw=peso] if e(sample)==1
testparm c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv c.neg_ft_tfp_solow_GMM_CD c.lag_bite010liv
local pval: display %-9.3f r(p)
outreg2 using table1, append tex excel dec(3) ctitle(Delta log Wage-All workers >10%)   addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, Yes,  p-value, `pval') keep(neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)


*Blue collars*

*<10%
reghdfe d.logwaged c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv $controls [aw=peso] if dum010liv==1 & (qual=="1") & mtm==1, absorb(anno id_lav#id_az) cluster(id_azienda id_lav) nocon
gen esampleclose=e(sample)
testparm c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv c.neg_ft_tfp_solow_GMM_CD c.lag_bite010liv
local pval: display %-9.3f r(p)
outreg2 using table1, append tex excel dec(3) ctitle(Delta log Wage-Blue collars 0-10%)  addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, Yes,  p-value, `pval') keep(neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)
*>10%
reghdfe d.logwaged c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv $controls [aw=peso] if dum010liv==0 & (qual=="1") & mtm==1, absorb(anno id_lav#id_az) cluster(id_azienda id_lav) nocon
sum c.lag_bite010liv [aw=peso] if e(sample)==1
gen esamplefar=e(sample)
testparm c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv c.neg_ft_tfp_solow_GMM_CD c.lag_bite010liv
local pval: display %-9.3f r(p)
outreg2 using table1, append tex excel dec(3) ctitle(Delta log Wage-Blue collars >10%) addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, Yes,  p-value, `pval') keep(neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)

*White collars*

*<10%
reghdfe d.logwaged c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv $controls [aw=peso] if dum010liv==1 & (qual=="2") & mtm==1, absorb(anno id_lav#id_az) cluster(id_azienda id_lav) nocon
testparm c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv c.neg_ft_tfp_solow_GMM_CD c.lag_bite010liv
local pval: display %-9.3f r(p)
outreg2 using table1, append tex excel dec(3) ctitle(Delta log Wage-White collars 0-10%) addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, Yes,  p-value, `pval') keep(neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)
*>10%
reghdfe d.logwaged c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv $controls [aw=peso] if dum010liv==0 & (qual=="2") & mtm==1, absorb(anno id_lav#id_az) cluster(id_azienda id_lav) nocon
testparm c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv c.neg_ft_tfp_solow_GMM_CD c.lag_bite010liv
local pval: display %-9.3f r(p)
outreg2 using table1, append tex excel dec(3) ctitle(Delta log Wage-White collars >10%) addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, Yes,  p-value, `pval') keep(neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)


***********
* Table 2 *
***********

*Job loss of blue collars*

*<10%
reghdfe job_loss c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv  [aw=peso] if dum010liv==1 & (qual=="1") & mtm==1, absorb(anno id_lav#id_az) cluster(id_azienda id_lav) nocon
testparm c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv c.neg_ft_tfp_solow_GMM_CD c.lag_bite010liv
local pval: display %-9.3f r(p)
outreg2 using table2, replace tex excel dec(3) ctitle(Job separation 0-10%) addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, Yes,  p-value, `pval') keep(neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)

*>10%
reghdfe job_loss c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv  [aw=peso] if dum010liv==0 & (qual=="1") & mtm==1, absorb(anno id_lav#id_az) cluster(id_azienda id_lav) nocon
testparm c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv c.neg_ft_tfp_solow_GMM_CD c.lag_bite010liv
local pval: display %-9.3f r(p)
outreg2 using table2, append tex excel dec(3) ctitle(Job separation >10%) addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, Yes, p-value, `pval') keep(neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)

clear

use "earnings.dta"

cd "..."


*Earnings of blue collars*

*<10%
sort id_lav anno
reghdfe dlogwaged c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv [aw=peso] if dum010liv==1 & qual=="1" & mtm==1, absorb(anno id_lav#id_az) vce(cluster id_azienda id_lav) nocon
outreg2 using table2, append tex excel dec(3) ctitle(Delta log Labor Earnings 0-10%) addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, No) keep(c.neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)


*>10%
sort id_lav anno
reghdfe dlogwaged c.neg_ft_tfp_solow_GMM_CD##c.lag_bite010liv [aw=peso] if dum010liv==0 & qual=="1" & mtm==1, absorb(anno id_lav#id_az) vce(cluster id_azienda id_lav) nocon
outreg2 using table2, append tex excel dec(3) ctitle(Delta log Labor Earnings >10%) addtext(Worker-Establishment FE, Yes, Year FE, Yes, Controls, No) keep(c.neg_ft_tfp_solow_GMM_CD c.neg_ft_tfp_solow_GMM_CD#c.lag_bite010liv)